package cn.maihe.elg.operation.web.bank;

import cn.maihe.elg.operation.model.dto.BaseResponse;
import cn.maihe.elg.operation.model.vo.bank.BankStatementDetailVo;
import cn.maihe.elg.operation.model.vo.bank.ListBankStatementVO;
import cn.maihe.elg.operation.repository.entity.SpdBankNotice;
import cn.maihe.elg.operation.service.bank.BankStatementService;
import cn.maihe.framework.starter.base.sql.PageBo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Api(value = "银行流水管理", tags = "银行流水管理")
@RestController
@RequestMapping("/api")
@Slf4j
public class BankStatementController {

    @Resource
    private BankStatementService bankStatementService;

    @ApiOperation(value = "查询银行流水列表", notes = "查询银行流水列表")
    @RequestMapping(value = "/bankStatement/list", method = RequestMethod.GET)
    public PageBo<SpdBankNotice> selectBankStatementList(int pageNo, int pageSize, ListBankStatementVO ListBankStatementVO) {
        PageBo<SpdBankNotice> spdBankNotices = bankStatementService.selectBankStatementList(pageNo, pageSize,ListBankStatementVO);
        return spdBankNotices;
    }

    @ApiOperation(value = "查询银行流水详情", notes = "根据银行流水id查询流水详情")
    @ApiImplicitParam(name = "id", value = "银行流水id", dataType = "Long", paramType = "path", required = true)
    @RequestMapping(value = "/bankStatement/{id}", method = RequestMethod.GET)
    public BaseResponse<Object> getSpdBankNoticeById(@PathVariable Long id){
        BankStatementDetailVo bankStatementById = bankStatementService.selectBankStatementById(id);
        if (Objects.isNull(bankStatementById)) {
            return BaseResponse.error("无查找内容");
        }
        return BaseResponse.success(bankStatementById);
    }

}
